﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace RemoteSensingImageDirectServer.Migrations
{
    public partial class RasterMapCache : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TBGroupImages",
                columns: table => new
                {
                    Key = table.Column<string>(type: "TEXT", nullable: false),
                    GroupName = table.Column<string>(type: "TEXT", nullable: false),
                    TableName = table.Column<string>(type: "TEXT", nullable: false),
                    MapConfig = table.Column<string>(type: "TEXT", nullable: false),
                    CreateBy = table.Column<string>(type: "TEXT", nullable: false),
                    VrtData = table.Column<byte[]>(type: "BLOB", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TBGroupImages", x => x.Key);
                });

            migrationBuilder.CreateTable(
                name: "TBSingleImages",
                columns: table => new
                {
                    Key = table.Column<string>(type: "TEXT", nullable: false),
                    Filename = table.Column<string>(type: "TEXT", nullable: false),
                    EPSG = table.Column<int>(type: "INTEGER", nullable: false),
                    WarpData = table.Column<byte[]>(type: "BLOB", nullable: true),
                    VrtData = table.Column<byte[]>(type: "BLOB", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TBSingleImages", x => x.Key);
                });

            migrationBuilder.CreateTable(
                name: "TBGroupImageWarp",
                columns: table => new
                {
                    Key = table.Column<string>(type: "TEXT", nullable: false),
                    GroupKey = table.Column<string>(type: "TEXT", nullable: false),
                    WarpData = table.Column<byte[]>(type: "BLOB", nullable: false),
                    ParentKey = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TBGroupImageWarp", x => x.Key);
                    table.ForeignKey(
                        name: "FK_TBGroupImageWarp_TBGroupImages_ParentKey",
                        column: x => x.ParentKey,
                        principalTable: "TBGroupImages",
                        principalColumn: "Key");
                });

            migrationBuilder.CreateIndex(
                name: "IX_TBGroupImages_GroupName_CreateBy",
                table: "TBGroupImages",
                columns: new[] { "GroupName", "CreateBy" });

            migrationBuilder.CreateIndex(
                name: "IX_TBGroupImageWarp_ParentKey",
                table: "TBGroupImageWarp",
                column: "ParentKey");

            migrationBuilder.CreateIndex(
                name: "IX_TBSingleImages_Filename_EPSG",
                table: "TBSingleImages",
                columns: new[] { "Filename", "EPSG" });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "TBGroupImageWarp");

            migrationBuilder.DropTable(
                name: "TBSingleImages");

            migrationBuilder.DropTable(
                name: "TBGroupImages");
        }
    }
}
